package com.qu.waibao.my.activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;

import com.qu.waibao.R;
import com.qu.waibao.base.BaseActivity;
import com.qu.waibao.interf.XnetCallBack;
import com.qu.waibao.network.ActionUtil;
import com.qu.waibao.network.NetManager;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import butterknife.OnClick;

public class AboutMeActivity extends BaseActivity implements View.OnClickListener{
    @BindView(R.id.tv_title)
    TextView tv_title;
   @BindView(R.id.mWebView)
   WebView mWebView;
    @BindView(R.id.iv_publish)
   ImageView iv_publish;
    @Override
    protected int getContentView() {
        return R.layout.activity_about_me;
    }

    @Override
    protected void initWidget() {
        super.initWidget();
        iv_publish.setVisibility(View.GONE);
        mWebView.getSettings().setJavaScriptEnabled(true);
        tv_title.setText("关于我们");
    }

    @Override
    protected void initData() {
        super.initData();
        requestData();
    }

    public void requestData(){
        Map<String,String> map = new HashMap<>();
        map.put("action", ActionUtil.textinfo_get);
        map.put("infotype","5");
        NetManager.getInstance().request(this, map, true, new XnetCallBack() {
            @Override
            public void onSuccess(String result, String msg) {
                try {
                    JSONObject jsonObject = new JSONObject(result);
                    mWebView.loadDataWithBaseURL(null,jsonObject.optString("content"),"text/html",
                            "UTF-8",null);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {

            }

            @Override
            public void onFinished() {

            }
        });
    }
    @OnClick(R.id.ll_back)
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.ll_back:
                finish();
                break;
        }
    }
}
